﻿namespace Factory.Service
{
    using System;
    using System.Web.UI;

    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                System.Configuration.ClientSettingsSection config =
                    (System.Configuration.ClientSettingsSection)System.Configuration.ConfigurationManager.GetSection("applicationSettings/BadHabit.Factory.Properties.Settings");

                this.FactoryCompanyName.Text = config.Settings.Get("FactoryCompanyName").Value.ValueXml.InnerText;
                this.FactoryEmailAccount.Text = config.Settings.Get("FactoryEmailAccount").Value.ValueXml.InnerText;

                this.FactoryEmailAccount.NavigateUrl = "mailto: " + this.FactoryEmailAccount.Text;
                string serverName = Request.Url.AbsoluteUri.Substring(0, Request.Url.AbsoluteUri.ToLower().IndexOf("/default.aspx"));
                this.accessButton.NavigateUrl = config.Settings.Get("ClientLaunchServerUrl").Value.ValueXml.InnerText + "?ServerUrl=" + serverName;
                this.accessButton.Text = this.accessButton.NavigateUrl;

                this.Response.Write("<USER " + Page.User.Identity.Name + " />");
            }
        }
    }
}
